import { _decorator, Component, Label, Node, Slider, Sprite, Toggle, Vec2, Vec3 } from 'cc';
import { UIManager } from '../UIManager';
import { LanauageManager } from '../LanauageManager';
import { GameData, inviteRewardCfg, shopCfg } from '../GameData';
import { HttpClient } from '../net/HttpClient';
import { EventManager } from '../EventManager';
import { AudioMgr } from '../AudioMgr';
const { ccclass, property } = _decorator;

@ccclass('inviteItem')
export class inviteItem extends Component {

    @property(Node)
    line:Node = null;

    @property(Node)
    bgComp:Node = null;

    @property(Label)
    roleNumLab:Label = null;

    @property(Label)
    coinLab:Label = null;

    @property(Label)
    rewardLab:Label = null;

    rewardCfg:inviteRewardCfg;

    onEnable() {

    }

    refresh(inviteRewardCfg:any, index:number){
        this.rewardCfg = inviteRewardCfg;

        this.line.active = index%5==0 ? false : true;

        if(this.rewardCfg.id == 14){
            this.roleNumLab.string = "每人";
            this.bgComp.active = false;
            this.line.active = false;
        }else{
            this.roleNumLab.string = this.rewardCfg.inviteNum + "人";
            this.bgComp.active = GameData.getIns().userData.inviteNum >= this.rewardCfg.inviteNum;
        }

        this.coinLab.string = this.rewardCfg.rewardCoin + "";

        if (this.rewardCfg.rewardShopId > 0){
            let cfg:shopCfg = GameData.getItemDataByIdAndCfgs(this.rewardCfg.rewardShopId, GameData.shopCfgs);
            this.rewardLab.string = cfg.name;
        }else{
            this.rewardLab.string = "";
        }
    }

    onClickHandler(event:Event, str:string){
        if (str == "share"){

        }else if (str == "save"){
            
        }
    }
}

